use COMBINED_waves_1234.dta, replace


***Import Disconnections Spreadsheet****
import delimited "disconnections_spreadsheet_may_seasonal.csv", numericcols(1) clear
*rename ïstate state


save "disconnection_policies_may_seasonal.dta", replace

/*
import delimited "seasonal_spreadsheet", numericcols(1) clear
rename ïstate state


save "disconnection_policies_may_seasonal.dta", replace
*/



***Merge survey data with disconnections data****
use disconnection_policies_may_seasonal.dta, clear
sort state
merge 1:m state using energy_insecurity_combined_waves1234_may.dta, nogenerate
sort state

***Label states**
label define state_labels 1 "Alabama" 2 "Alaska" 3 "Arizona" 4 "Arkansas" 5 "California" 6 "Colorado" 7 "Connecticut" 8 "Delaware" 9 "District of Columbia" 10 "Florida" 11 "Georgia" 12 "Hawaii" 13 "Idaho" 14 "Illinois" 15 "Indiana" 16 "Iowa" 17 "Kansas" 18 "Kentucky" 19 "Louisiana" 20 "Maine" 21 "Maryland" 22 "Massachusetts" 23 "Michigan" 24 "Minnesota" 25 "Mississippi" 26 "Missouri" 27 "Montana" 28 "Nebraska" 29 "Nevada" 30 "New Hampshire" 31 "New Jersey" 32 "New Mexico" 33 "New York" 34 "North Carolina" 35 "North Dakota" 36 "Ohio" 37 "Oklahoma" 38 "Oregon" 39 "Pennsylvania" 40 "Rhode Island" 41 "South Carolina" 42 "South Dakota" 43 "Tennessee" 44 "Texas" 45 "Utah" 46 "Vermont" 47 "Virginia" 48 "Washington" 49 "West Virginia" 50 "Wisconsin" 51 "Wyoming"
label values state state_labels



save ei_survey_policy_v4_seasonal.dta, replace

****Merge additional zip-code matched respondents***
use missing2, replace
gen utility_type=.
replace utility_type=1 if muni==1
replace utility_type=2 if iou==1
replace utility_type=3 if coop==1
label define utilitylabel 1 "Municipal" 2 "IOU" 3 "Coop" 4 "Special District" 5 "Federal"
label values utility_type utilitylabel

merge 1:m caseid_w1 using ei_survey_policy_v4_seasonal, nogenerate

save ei_survey_policy_v4_seasonal, replace

****Collapse dataset into variable of interest for each month, rename variables into common names, and append****
******May Data******
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight1 caseid_National caseid_Indiana caseid_w1 inputzip1 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_may moratorium_may_days voluntary_may voluntary_may_days disconnect_may caseid_National hhsize1 employ1 gender black hispanic educ1 unemployed1 marstat inputzip1 hh_under51 hh_over651 hh_disability1 covid_foregoexpenses1 hhbill_may notice_may age energy_assistance_may gov_assistance_may income1 under_100_fpl1 electronic_device1 covid_stimulus_yr wap_may liheap_may snap_may tanf_may ssi_may medicaid_may vet_benefits_may unemp_insurance_may gov_agency_may energy_provider_may friend_family_may faith_org_may nonprofit_may payday_lender_may bankloan_may ownhome1 fuel_payment1 dwelling_type1

drop if hhbill_may==.

gen month=1

rename weight4 weight_balanced
rename weight1 weight
rename inputzip1 inputzip
rename hhsize1 hhsize
rename employ1 employ
rename educ1 educ
rename unemployed1 unemployed
rename hh_under51 hh_under5
rename hh_over651 hh_over65
rename hh_disability1 hh_disability
rename income1 income
rename under_100_fpl1 under_100_fpl
rename moratorium_may moratorium
rename moratorium_may_days moratorium_days
rename voluntary_may voluntary
rename voluntary_may_days voluntary_days
rename disconnect_may disconnected
rename covid_foregoexpenses1 forego_expenses
rename hhbill_may hhbill
rename notice_may notice
rename energy_assistance_may energy_assistance
rename gov_assistance_may gov_assistance
rename electronic_device1 device
rename covid_stimulus_yr stimulus
rename wap_may wap
rename liheap_may liheap
rename snap_may snap
rename tanf_may tanf
rename ssi_may ssi
rename medicaid_may medicaid
rename vet_benefits_may vet_benefits
rename unemp_insurance_may unemp_insurance
rename gov_agency_may gov_agency
rename energy_provider_may energy_provider
rename friend_family_may friend_family
rename faith_org_may faith_org
rename nonprofit_may nonprofit
rename payday_lender_may payday_lender
rename bankloan_may bankloan
rename ownhome1 ownhome
rename fuel_payment1 fuel_payment
rename dwelling_type1 dwelling_type

gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1


gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1

gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save may_policy_v4_seasonal.dta, replace


*******June Data********
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight2 caseid_National caseid_Indiana caseid_w1 inputzip2 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_june moratorium_june_days voluntary_june voluntary_june_days disconnect_june caseid_National hhsize2 employ2 gender black hispanic educ2 unemployed2 marstat inputzip2 hh_under52 hh_over652 hh_disability2 forego_expenses_june hhbill_june notice_june age energy_assistance_june gov_assistance_june income2 under_100_fpl2 electronic_device2 stimulus_june wap_may wap_june liheap_june snap_june tanf_june ssi_june medicaid_june vet_benefits_june unemp_insurance_june gov_agency_june energy_provider_june friend_family_june faith_org_june nonprofit_june payday_lender_june bankloan_june ownhome2 fuel_payment2 dwelling_type2

drop if hhbill_june==.

gen month=2

rename weight4 weight_balanced
rename weight2 weight
rename inputzip2 inputzip
rename hhsize2 hhsize
rename employ2 employ
rename educ2 educ
rename unemployed2 unemployed
rename hh_under52 hh_under5
rename hh_over652 hh_over65
rename hh_disability2 hh_disability
rename income2 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl2==1
rename moratorium_june moratorium
rename moratorium_june_days moratorium_days
rename voluntary_june voluntary
rename voluntary_june_days voluntary_days
rename disconnect_june disconnected
rename forego_expenses_june forego_expenses
rename hhbill_june hhbill
rename notice_june notice
rename energy_assistance_june energy_assistance
rename gov_assistance_june gov_assistance
rename electronic_device2 device
rename stimulus_june stimulus
rename wap_june wap
rename liheap_june liheap
rename snap_june snap
rename tanf_june tanf
rename ssi_june ssi
rename medicaid_june medicaid
rename vet_benefits_june vet_benefits
rename unemp_insurance_june unemp_insurance
rename gov_agency_june gov_agency
rename energy_provider_june energy_provider
rename friend_family_june friend_family
rename faith_org_june faith_org
rename nonprofit_june nonprofit
rename payday_lender_june payday_lender
rename bankloan_june bankloan
rename ownhome2 ownhome
rename fuel_payment2 fuel_payment
rename dwelling_type2 dwelling_type


gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1

gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save june_policy_v4_seasonal.dta, replace



*******July Data********
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight2 caseid_National caseid_Indiana caseid_w1 inputzip2 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_july moratorium_july_days voluntary_july voluntary_july_days disconnect_july caseid_National hhsize2 employ2 gender black hispanic educ2 unemployed2 marstat inputzip2 hh_under52 hh_over652 hh_disability2 forego_expenses_july hhbill_july notice_july age energy_assistance_july gov_assistance_july income2 under_100_fpl2 electronic_device2 stimulus_july wap_july liheap_july snap_july tanf_july ssi_july medicaid_july vet_benefits_july unemp_insurance_july gov_agency_july energy_provider_july friend_family_july faith_org_july nonprofit_july payday_lender_july bankloan_july ownhome2 fuel_payment2 dwelling_type2

drop if hhbill_july==.

gen month=3

rename weight4 weight_balanced
rename weight2 weight
rename inputzip2 inputzip
rename hhsize2 hhsize
rename employ2 employ
rename educ2 educ
rename unemployed2 unemployed
rename hh_under52 hh_under5
rename hh_over652 hh_over65
rename hh_disability2 hh_disability
rename income2 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl2==1
rename moratorium_july moratorium
rename moratorium_july_days moratorium_days
rename voluntary_july voluntary
rename voluntary_july_days voluntary_days
rename disconnect_july disconnected
rename forego_expenses_july forego_expenses
rename hhbill_july hhbill
rename notice_july notice
rename energy_assistance_july energy_assistance
rename gov_assistance_july gov_assistance
rename electronic_device2 device
rename stimulus_july stimulus
rename wap_july wap
rename liheap_july liheap
rename snap_july snap
rename tanf_july tanf
rename ssi_july ssi
rename medicaid_july medicaid
rename vet_benefits_july vet_benefits
rename unemp_insurance_july unemp_insurance
rename gov_agency_july gov_agency
rename energy_provider_july energy_provider
rename friend_family_july friend_family
rename faith_org_july faith_org
rename nonprofit_july nonprofit
rename payday_lender_july payday_lender
rename bankloan_july bankloan
rename ownhome2 ownhome
rename fuel_payment2 fuel_payment
rename dwelling_type2 dwelling_type





gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1

gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save july_policy_v4_seasonal.dta, replace




*******August Data********
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight2 caseid_National caseid_Indiana caseid_w1 inputzip2 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_august moratorium_august_days voluntary_august voluntary_august_days disconnect_august caseid_National hhsize2 employ2 gender black hispanic educ2 unemployed2 marstat inputzip2 hh_under52 hh_over652 hh_disability2 forego_expenses_august hhbill_august notice_august age energy_assistance_august gov_assistance_august income2 under_100_fpl2 electronic_device2 stimulus_august wap_august liheap_august snap_august tanf_august ssi_august medicaid_august vet_benefits_august unemp_insurance_august gov_agency_august energy_provider_august friend_family_august faith_org_august nonprofit_august payday_lender_august bankloan_august ownhome2 fuel_payment2 dwelling_type2


drop if hhbill_august==.

gen month=4

rename weight4 weight_balanced
rename weight2 weight
rename inputzip2 inputzip
rename hhsize2 hhsize
rename employ2 employ
rename educ2 educ
rename unemployed2 unemployed
rename hh_under52 hh_under5
rename hh_over652 hh_over65
rename hh_disability2 hh_disability
rename income2 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl2==1
rename moratorium_august moratorium
rename moratorium_august_days moratorium_days
rename voluntary_august voluntary
rename voluntary_august_days voluntary_days
rename disconnect_august disconnected
rename forego_expenses_august forego_expenses
rename hhbill_august hhbill
rename notice_august notice
rename energy_assistance_august energy_assistance
rename gov_assistance_august gov_assistance
rename electronic_device2 device
rename stimulus_august stimulus
rename wap_august wap
rename liheap_august liheap
rename snap_august snap
rename tanf_august tanf
rename ssi_august ssi
rename medicaid_august medicaid
rename vet_benefits_august vet_benefits
rename unemp_insurance_august unemp_insurance
rename gov_agency_august gov_agency
rename energy_provider_august energy_provider
rename friend_family_august friend_family
rename faith_org_august faith_org
rename nonprofit_august nonprofit
rename payday_lender_august payday_lender
rename bankloan_august bankloan
rename ownhome2 ownhome
rename fuel_payment2 fuel_payment
rename dwelling_type2 dwelling_type




gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save august_policy_v4_seasonal.dta, replace


***September Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight3 caseid_National caseid_Indiana caseid_w1 inputzip3 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_september moratorium_september_days voluntary_september voluntary_september_days disconnect_september caseid_National hhsize3 employ3 gender black hispanic educ3 unemployed3 marstat inputzip3 hh_under53 hh_over653 hh_disability3 forego_expenses_september hhbill_september notice_september age energy_assistance_september gov_assistance_september income3 under_100_fpl3 electronic_device3 stimulus_september wap_september liheap_september snap_september tanf_september ssi_september medicaid_september vet_benefits_september unemp_insurance_september gov_agency_september energy_provider_september friend_family_september faith_org_september nonprofit_september payday_lender_september bankloan_september ownhome3 fuel_payment3 dwelling_type3


drop if hhbill_september==.

gen month=5

rename weight4 weight_balanced
rename weight3 weight
rename inputzip3 inputzip
rename hhsize3 hhsize
rename employ3 employ
rename educ3 educ
rename unemployed3 unemployed
rename hh_under53 hh_under5
rename hh_over653 hh_over65
rename hh_disability3 hh_disability
rename income3 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl3==1
rename moratorium_september moratorium
rename moratorium_september_days moratorium_days
rename voluntary_september voluntary
rename voluntary_september_days voluntary_days
rename disconnect_september disconnected
rename forego_expenses_september forego_expenses
rename hhbill_september hhbill
rename notice_september notice
rename energy_assistance_september energy_assistance
rename gov_assistance_september gov_assistance
rename electronic_device3 device
rename stimulus_september stimulus
rename wap_september wap
rename liheap_september liheap
rename snap_september snap
rename tanf_september tanf
rename ssi_september ssi
rename medicaid_september medicaid
rename vet_benefits_september vet_benefits
rename unemp_insurance_september unemp_insurance
rename gov_agency_september gov_agency
rename energy_provider_september energy_provider
rename friend_family_september friend_family
rename faith_org_september faith_org
rename nonprofit_september nonprofit
rename payday_lender_september payday_lender
rename bankloan_september bankloan
rename ownhome3 ownhome
rename fuel_payment3 fuel_payment
rename dwelling_type3 dwelling_type



gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1


gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save september_policy_v4_seasonal.dta, replace



***october Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight3 caseid_National caseid_Indiana caseid_w1 inputzip3 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_october moratorium_october_days voluntary_october voluntary_october_days disconnect_october caseid_National hhsize3 employ3 gender black hispanic educ3 unemployed3 marstat inputzip3 hh_under53 hh_over653 hh_disability3 forego_expenses_october hhbill_october notice_october age energy_assistance_october gov_assistance_october income3 under_100_fpl3 electronic_device3 stimulus_october wap_october liheap_october snap_october tanf_october ssi_october medicaid_october vet_benefits_october unemp_insurance_october gov_agency_october energy_provider_october friend_family_october faith_org_october nonprofit_october payday_lender_october bankloan_october ownhome3 fuel_payment3 dwelling_type3

drop if hhbill_october==.

gen month=6

rename weight4 weight_balanced
rename weight3 weight
rename inputzip3 inputzip
rename hhsize3 hhsize
rename employ3 employ
rename educ3 educ
rename unemployed3 unemployed
rename hh_under53 hh_under5
rename hh_over653 hh_over65
rename hh_disability3 hh_disability
rename income3 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl3==1
rename moratorium_october moratorium
rename moratorium_october_days moratorium_days
rename voluntary_october voluntary
rename voluntary_october_days voluntary_days
rename disconnect_october disconnected
rename forego_expenses_october forego_expenses
rename hhbill_october hhbill
rename notice_october notice
rename energy_assistance_october energy_assistance
rename gov_assistance_october gov_assistance
rename electronic_device3 device
rename stimulus_october stimulus
rename wap_october wap
rename liheap_october liheap
rename snap_october snap
rename tanf_october tanf
rename ssi_october ssi
rename medicaid_october medicaid
rename vet_benefits_october vet_benefits
rename unemp_insurance_october unemp_insurance
rename gov_agency_october gov_agency
rename energy_provider_october energy_provider
rename friend_family_october friend_family
rename faith_org_october faith_org
rename nonprofit_october nonprofit
rename payday_lender_october payday_lender
rename bankloan_october bankloan
rename ownhome3 ownhome
rename fuel_payment3 fuel_payment
rename dwelling_type3 dwelling_type



gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1


gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save october_policy_v4_seasonal.dta, replace





***November Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight3 caseid_National caseid_Indiana caseid_w1 inputzip3 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_november moratorium_november_days voluntary_november voluntary_november_days disconnect_november caseid_National hhsize3 employ3 gender black hispanic educ3 unemployed3 marstat inputzip3 hh_under53 hh_over653 hh_disability3 forego_expenses_november hhbill_november notice_november age energy_assistance_november gov_assistance_november income3 under_100_fpl3 electronic_device3 stimulus_november wap_november liheap_november snap_november tanf_november ssi_november medicaid_november vet_benefits_november unemp_insurance_november gov_agency_november energy_provider_november friend_family_november faith_org_november nonprofit_november payday_lender_november bankloan_november ownhome3 fuel_payment3 dwelling_type3

drop if hhbill_november==.

gen month=7

rename weight4 weight_balanced
rename weight3 weight
rename inputzip3 inputzip
rename hhsize3 hhsize
rename employ3 employ
rename educ3 educ
rename unemployed3 unemployed
rename hh_under53 hh_under5
rename hh_over653 hh_over65
rename hh_disability3 hh_disability
rename income3 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl3==1
rename moratorium_november moratorium
rename moratorium_november_days moratorium_days
rename voluntary_november voluntary
rename voluntary_november_days voluntary_days
rename disconnect_november disconnected
rename forego_expenses_november forego_expenses
rename hhbill_november hhbill
rename notice_november notice
rename energy_assistance_november energy_assistance
rename gov_assistance_november gov_assistance
rename electronic_device3 device
rename stimulus_november stimulus
rename wap_november wap
rename liheap_november liheap
rename snap_november snap
rename tanf_november tanf
rename ssi_november ssi
rename medicaid_november medicaid
rename vet_benefits_november vet_benefits
rename unemp_insurance_november unemp_insurance
rename gov_agency_november gov_agency
rename energy_provider_november energy_provider
rename friend_family_november friend_family
rename faith_org_november faith_org
rename nonprofit_november nonprofit
rename payday_lender_november payday_lender
rename bankloan_november bankloan
rename ownhome3 ownhome
rename fuel_payment3 fuel_payment
rename dwelling_type3 dwelling_type




gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1


gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save november_policy_v4_seasonal.dta, replace



***December Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight3 caseid_National caseid_Indiana caseid_w1 inputzip3 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_december moratorium_december_days voluntary_december voluntary_december_days disconnect_december caseid_National hhsize3 employ3 gender black hispanic educ3 unemployed3 marstat inputzip3 hh_under53 hh_over653 hh_disability3 forego_expenses_december hhbill_december notice_december age energy_assistance_december gov_assistance_december income3 under_100_fpl3 electronic_device3 stimulus_december wap_december liheap_december snap_december tanf_december ssi_december medicaid_december vet_benefits_december unemp_insurance_december gov_agency_december energy_provider_december friend_family_december faith_org_december nonprofit_december payday_lender_december bankloan_december ownhome3 fuel_payment3 dwelling_type3


drop if hhbill_december==.

gen month=8

rename weight4 weight_balanced
rename weight3 weight
rename inputzip3 inputzip
rename hhsize3 hhsize
rename employ3 employ
rename educ3 educ
rename unemployed3 unemployed
rename hh_under53 hh_under5
rename hh_over653 hh_over65
rename hh_disability3 hh_disability
rename income3 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl3==1
rename moratorium_december moratorium
rename moratorium_december_days moratorium_days
rename voluntary_december voluntary
rename voluntary_december_days voluntary_days
rename disconnect_december disconnected
rename forego_expenses_december forego_expenses
rename hhbill_december hhbill
rename notice_december notice
rename energy_assistance_december energy_assistance
rename gov_assistance_december gov_assistance
rename electronic_device3 device
rename stimulus_december stimulus
rename wap_december wap
rename liheap_december liheap
rename snap_december snap
rename tanf_december tanf
rename ssi_december ssi
rename medicaid_december medicaid
rename vet_benefits_december vet_benefits
rename unemp_insurance_december unemp_insurance
rename gov_agency_december gov_agency
rename energy_provider_december energy_provider
rename friend_family_december friend_family
rename faith_org_december faith_org
rename nonprofit_december nonprofit
rename payday_lender_december payday_lender
rename bankloan_december bankloan
rename ownhome3 ownhome
rename fuel_payment3 fuel_payment
rename dwelling_type3 dwelling_type



gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1


gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save december_policy_v4_seasonal.dta, replace


***January Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 weight3 caseid_National caseid_Indiana caseid_w1 inputzip3 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_january moratorium_january_days voluntary_january voluntary_january_days disconnect_january caseid_National hhsize3 employ3 gender black hispanic educ3 unemployed3 marstat inputzip3 hh_under53 hh_over653 hh_disability3 forego_expenses_january hhbill_january notice_january age energy_assistance_january gov_assistance_january income3 under_100_fpl3 electronic_device3 stimulus_january wap_january liheap_january snap_january tanf_january ssi_january medicaid_january vet_benefits_january unemp_insurance_january gov_agency_january energy_provider_january friend_family_january faith_org_january nonprofit_january payday_lender_january bankloan_january ownhome3 fuel_payment3 dwelling_type3


drop if hhbill_january==.

gen month=9

rename weight4 weight_balanced
rename weight3 weight
rename inputzip3 inputzip
rename hhsize3 hhsize
rename employ3 employ
rename educ3 educ
rename unemployed3 unemployed
rename hh_under53 hh_under5
rename hh_over653 hh_over65
rename hh_disability3 hh_disability
rename income3 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl3==1
rename moratorium_january moratorium
rename moratorium_january_days moratorium_days
rename voluntary_january voluntary
rename voluntary_january_days voluntary_days
rename disconnect_january disconnected
rename forego_expenses_january forego_expenses
rename hhbill_january hhbill
rename notice_january notice
rename energy_assistance_january energy_assistance
rename gov_assistance_january gov_assistance
rename electronic_device3 device
rename stimulus_january stimulus
rename wap_january wap
rename liheap_january liheap
rename snap_january snap
rename tanf_january tanf
rename ssi_january ssi
rename medicaid_january medicaid
rename vet_benefits_january vet_benefits
rename unemp_insurance_january unemp_insurance
rename gov_agency_january gov_agency
rename energy_provider_january energy_provider
rename friend_family_january friend_family
rename faith_org_january faith_org
rename nonprofit_january nonprofit
rename payday_lender_january payday_lender
rename bankloan_january bankloan
rename ownhome3 ownhome
rename fuel_payment3 fuel_payment
rename dwelling_type3 dwelling_type


gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save january_policy_v4_seasonal.dta, replace


***February Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 caseid_National caseid_Indiana caseid_w1 inputzip4 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_february moratorium_february_days voluntary_february voluntary_february_days disconnect_february caseid_National hhsize4 employ4 gender black hispanic educ4 unemployed4 marstat inputzip4 hh_under54 hh_over654 hh_disability4 forego_expenses_february hhbill_february notice_february age energy_assistance_february gov_assistance_february income4 under_100_fpl4 electronic_device4 stimulus_february wap_february liheap_february snap_february tanf_february ssi_february medicaid_february vet_benefits_february unemp_insurance_february gov_agency_february energy_provider_february friend_family_february faith_org_february nonprofit_february payday_lender_february bankloan_february ownhome4 fuel_payment4 dwelling_type4


drop if hhbill_february==.

gen month=10

clonevar weight_balanced = weight4
rename weight4 weight
rename inputzip4 inputzip
rename hhsize4 hhsize
rename employ4 employ
rename educ4 educ
rename unemployed4 unemployed
rename hh_under54 hh_under5
rename hh_over654 hh_over65
rename hh_disability4 hh_disability
rename income4 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl4==1
rename moratorium_february moratorium
rename moratorium_february_days moratorium_days
rename voluntary_february voluntary
rename voluntary_february_days voluntary_days
rename disconnect_february disconnected
rename forego_expenses_february forego_expenses
rename hhbill_february hhbill
rename notice_february notice
rename energy_assistance_february energy_assistance
rename gov_assistance_february gov_assistance
rename electronic_device4 device
rename stimulus_february stimulus
rename wap_february wap
rename liheap_february liheap
rename snap_february snap
rename tanf_february tanf
rename ssi_february ssi
rename medicaid_february medicaid
rename vet_benefits_february vet_benefits
rename unemp_insurance_february unemp_insurance
rename gov_agency_february gov_agency
rename energy_provider_february energy_provider
rename friend_family_february friend_family
rename faith_org_february faith_org
rename nonprofit_february nonprofit
rename payday_lender_february payday_lender
rename bankloan_february bankloan
rename ownhome4 ownhome
rename fuel_payment4 fuel_payment
rename dwelling_type4 dwelling_type


gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save february_policy_v4_seasonal.dta, replace


***march Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 caseid_National caseid_Indiana caseid_w1 inputzip4 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_march moratorium_march_days voluntary_march voluntary_march_days disconnect_march caseid_National hhsize4 employ4 gender black hispanic educ4 unemployed4 marstat inputzip4 hh_under54 hh_over654 hh_disability4 forego_expenses_march hhbill_march notice_march age energy_assistance_march gov_assistance_march income4 under_100_fpl4 electronic_device4 stimulus_march wap_march liheap_march snap_march tanf_march ssi_march medicaid_march vet_benefits_march unemp_insurance_march gov_agency_march energy_provider_march friend_family_march faith_org_march nonprofit_march payday_lender_march bankloan_march ownhome4 fuel_payment4 dwelling_type4


drop if hhbill_march==.

gen month=11

clonevar weight_balanced = weight4
rename weight4 weight
rename inputzip4 inputzip
rename hhsize4 hhsize
rename employ4 employ
rename educ4 educ
rename unemployed4 unemployed
rename hh_under54 hh_under5
rename hh_over654 hh_over65
rename hh_disability4 hh_disability
rename income4 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl4==1
rename moratorium_march moratorium
rename moratorium_march_days moratorium_days
rename voluntary_march voluntary
rename voluntary_march_days voluntary_days
rename disconnect_march disconnected
rename forego_expenses_march forego_expenses
rename hhbill_march hhbill
rename notice_march notice
rename energy_assistance_march energy_assistance
rename gov_assistance_march gov_assistance
rename electronic_device4 device
rename stimulus_march stimulus
rename wap_march wap
rename liheap_march liheap
rename snap_march snap
rename tanf_march tanf
rename ssi_march ssi
rename medicaid_march medicaid
rename vet_benefits_march vet_benefits
rename unemp_insurance_march unemp_insurance
rename gov_agency_march gov_agency
rename energy_provider_march energy_provider
rename friend_family_march friend_family
rename faith_org_march faith_org
rename nonprofit_march nonprofit
rename payday_lender_march payday_lender
rename bankloan_march bankloan
rename ownhome4 ownhome
rename fuel_payment4 fuel_payment
rename dwelling_type4 dwelling_type


gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save march_policy_v4_seasonal.dta, replace



***april Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 caseid_National caseid_Indiana caseid_w1 inputzip4 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_april moratorium_april_days voluntary_april voluntary_april_days disconnect_april caseid_National hhsize4 employ4 gender black hispanic educ4 unemployed4 marstat inputzip4 hh_under54 hh_over654 hh_disability4 forego_expenses_april hhbill_april notice_april age energy_assistance_april gov_assistance_april income4 under_100_fpl4 electronic_device4 stimulus_april wap_april liheap_april snap_april tanf_april ssi_april medicaid_april vet_benefits_april unemp_insurance_april gov_agency_april energy_provider_april friend_family_april faith_org_april nonprofit_april payday_lender_april bankloan_april ownhome4 fuel_payment4 dwelling_type4


drop if hhbill_april==.

gen month=12

clonevar weight_balanced = weight4
rename weight4 weight
rename inputzip4 inputzip
rename hhsize4 hhsize
rename employ4 employ
rename educ4 educ
rename unemployed4 unemployed
rename hh_under54 hh_under5
rename hh_over654 hh_over65
rename hh_disability4 hh_disability
rename income4 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl4==1
rename moratorium_april moratorium
rename moratorium_april_days moratorium_days
rename voluntary_april voluntary
rename voluntary_april_days voluntary_days
rename disconnect_april disconnected
rename forego_expenses_april forego_expenses
rename hhbill_april hhbill
rename notice_april notice
rename energy_assistance_april energy_assistance
rename gov_assistance_april gov_assistance
rename electronic_device4 device
rename stimulus_april stimulus
rename wap_april wap
rename liheap_april liheap
rename snap_april snap
rename tanf_april tanf
rename ssi_april ssi
rename medicaid_april medicaid
rename vet_benefits_april vet_benefits
rename unemp_insurance_april unemp_insurance
rename gov_agency_april gov_agency
rename energy_provider_april energy_provider
rename friend_family_april friend_family
rename faith_org_april faith_org
rename nonprofit_april nonprofit
rename payday_lender_april payday_lender
rename bankloan_april bankloan
rename ownhome4 ownhome
rename fuel_payment4 fuel_payment
rename dwelling_type4 dwelling_type


gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save april_policy_v4_seasonal.dta, replace



***may2 Data***
use ei_survey_policy_v4_seasonal.dta, replace
keep weight4 caseid_National caseid_Indiana caseid_w1 inputzip4 marstat state utility utility_type muni iou coop iou_cov coop_cov muni_cov sd_cov fed_cov moratorium_may2 moratorium_may2_days voluntary_may2 voluntary_may2_days disconnect_may2 caseid_National hhsize4 employ4 gender black hispanic educ4 unemployed4 marstat inputzip4 hh_under54 hh_over654 hh_disability4 forego_expenses_may2 hhbill_may2 notice_may2 age energy_assistance_may2 gov_assistance_may2 income4 under_100_fpl4 electronic_device4 stimulus_may2 wap_may2 liheap_may2 snap_may2 tanf_may2 ssi_may2 medicaid_may2 vet_benefits_may2 unemp_insurance_may2 gov_agency_may2 energy_provider_may2 friend_family_may2 faith_org_may2 nonprofit_may2 payday_lender_may2 bankloan_may2 ownhome4 fuel_payment4 dwelling_type4


drop if hhbill_may2==.

gen month=13

clonevar weight_balanced = weight4
rename weight4 weight
rename inputzip4 inputzip
rename hhsize4 hhsize
rename employ4 employ
rename educ4 educ
rename unemployed4 unemployed
rename hh_under54 hh_under5
rename hh_over654 hh_over65
rename hh_disability4 hh_disability
rename income4 income
gen under_100_fpl=0
replace under_100_fpl=1 if under_100_fpl4==1
rename moratorium_may2 moratorium
rename moratorium_may2_days moratorium_days
rename voluntary_may2 voluntary
rename voluntary_may2_days voluntary_days
rename disconnect_may2 disconnected
rename forego_expenses_may2 forego_expenses
rename hhbill_may2 hhbill
rename notice_may2 notice
rename energy_assistance_may2 energy_assistance
rename gov_assistance_may2 gov_assistance
rename electronic_device4 device
rename stimulus_may2 stimulus
rename wap_may2 wap
rename liheap_may2 liheap
rename snap_may2 snap
rename tanf_may2 tanf
rename ssi_may2 ssi
rename medicaid_may2 medicaid
rename vet_benefits_may2 vet_benefits
rename unemp_insurance_may2 unemp_insurance
rename gov_agency_may2 gov_agency
rename energy_provider_may2 energy_provider
rename friend_family_may2 friend_family
rename faith_org_may2 faith_org
rename nonprofit_may2 nonprofit
rename payday_lender_may2 payday_lender
rename bankloan_may2 bankloan
rename ownhome4 ownhome
rename fuel_payment4 fuel_payment
rename dwelling_type4 dwelling_type


gen covered_moratorium=0
replace covered_moratorium=1 if moratorium==1 & utility_type==1 & muni_cov==1 
replace covered_moratorium=1 if moratorium==1 & utility_type==2 & iou_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==3 & coop_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==4 & sd_cov==1
replace covered_moratorium=1 if moratorium==1 & utility_type==5 & fed_cov==1

gen dayscovered_moratorium=0
replace dayscovered_moratorium = moratorium_days if covered_moratorium==1


gen covered_voluntary=0
replace covered_voluntary=1 if voluntary==1 & utility_type==1 & muni_cov==1 
replace covered_voluntary=1 if voluntary==1 & utility_type==2 & iou_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==3 & coop_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==4 & sd_cov==1
replace covered_voluntary=1 if voluntary==1 & utility_type==5 & fed_cov==1



gen dayscovered_voluntary=0
replace dayscovered_voluntary = voluntary_days if covered_voluntary==1


gen total_covered=0
replace total_covered=1 if covered_moratorium==1 | covered_voluntary==1
gen dayscovered_total=0
replace dayscovered_total = moratorium_days + voluntary_days if covered_moratorium==1 | covered_voluntary==1

save may2_policy_v4_seasonal.dta, replace



***Append datasets***
clear all

use may_policy_v4_seasonal.dta, clear
append using june_policy_v4_seasonal.dta
append using july_policy_v4_seasonal.dta
append using august_policy_v4_seasonal.dta
append using september_policy_v4_seasonal.dta
append using october_policy_v4_seasonal.dta
append using november_policy_v4_seasonal.dta
append using december_policy_v4_seasonal.dta
append using january_policy_v4_seasonal.dta
append using february_policy_v4_seasonal.dta
append using march_policy_v4_seasonal.dta
append using april_policy_v4_seasonal.dta
append using may2_policy_v4_seasonal.dta

save policy_combined_v4_seasonal.dta, replace
use policy_combined_v4_seasonal.dta, replace
